ShinyStudio

Overview

ShinyStudio is a Docker image which extends rocker/verse to include RStudio, Shiny Server, VS Code, and ShinyProxy.

ShinyStudio leverages ShinyProxy to provide:

  • a centralized, pre-configured development environment.
  • a centralized repository for documents written in Markdown, RMarkdown, or HTML.
  • a simple and secure method for sharing web apps developed with RStudio Shiny.

The ShinyStudio image consists of the products described below:

Branches

The GitHub repo for ShinyStudio contains two major branches: base and master.

  • The base branch is used to build the image published on DockerHub. The image is great for a personal instance, a quick demo, or the building blocks for a very customized setup.
  • The master branch builds upon the base image to provide an example of a more enterprise-ready setup of ShinyStudio.

Setup must be run as a non-root user.

Base

Setup of the base image can be done entirely with Docker.

First, create a network named shinystudio-net to be shared by all spawned containers.

docker network create shinystudio-net

Then, pull and run the ShinyStudio image directly from DockerHub.

docker run --rm -it --name shinyproxy \
    --network shinystudio-net \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -e USERID=$USERID \
    -e USER=$USER \
    -e PASSWORD=password \
    -e MOUNTPOINT="${HOME}/ShinyStudio" \
    -e SITEID=default \
    -p 8080:8080 \
    dm3ll3n/shinystudio

Once complete, open a web browser and navigate to http://<hostname>:8080. Log in with your username and the password password.

For a more customized experience, alter pertinent environment variables and bind local volumes to the Docker image. A more personalized setup could look like:

docker run --rm -it --name shinyproxy \
    --network shinystudio-net \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -e USERID=$USERID \
    -e USER=$USER \
    -e PASSWORD=p@ssw0rd123 \
    -e MOUNTPOINT="${HOME}/ShinyStudio" \
    -e SITEID=MyShinyStudio \
    -p 8080:8080 \
    -v "${PWD}/application.yml:/opt/shinyproxy/application.yml"
    -v "${PWD}/imgs/background.png:/opt/shinyproxy/templates/grid=layout/assets/img/background.png" \
    -v "${PWD}/imgs/logo.png:/opt/shinyproxy/templates/grid=layout/assets/img/logo.png"
    dm3ll3n/shinystudio

Explained:

  • MOUNTPOINT defines the path to store site content and user settings.
  • SITEID defines the folder name that this site’s content will reside in ($MOUNTPOINT/sites/$SITEID).
  • The bind mount for application.yml specifies a custom ShinyProxy configuration file (read more here).
  • Bind mounts for background.png and logo.png allow easy personalization of the site background and logo.

Master

Setup of the master branch requires both Docker and docker-compose.

For a more out-of-the-box setup, consider cloning/forking the master branch from GitHub. e.g.,

# Clone the master branch.
git clone https://github.com/dm3ll3n/ShinyStudio

# Enter the new directory.
cd ShinyStudio

# Setup and run.
./control.sh setup

The default mountpoint is $PWD/content. To specify another mountpoint, pass the desired path as an argument to the setup:

./control.sh setup "${HOME}/ShinyStudio"

Once complete, open a web browser and navigate to http://<hostname>:8080.

The default logins are:

  • user: user
  • admin: admin
  • superadmin: superadmin

Develop

Open your IDE of choice and notice two important directories:

  • __ShinyStudio__
  • __Personal__

Files must be saved in either of these two directories in order to persist between sessions.

These two folders are shared between instances RStudio, VS Code, and Shiny Server. So, creating new content is as simple as saving a file to the appropriate directory.

Tools

The ShinyStudio image comes with…

  • R
  • Python
  • PowerShell

…and ODBC drivers for:

  • SQL Server
  • PostgresSQL
  • Cloudera Impala.

These are persistent because they are built into the image.

Apps / drivers installed through RStudio/VS Code will not persist.

Libraries for R, Python, and PowerShell will persist. Additionally, user workspace settings (e.g. themes) are persistent.

Configuration

The details below apply only to the master branch setup.

Security

Authentication is managed by ShinyProxy, which supports basic auth, LDAP, Kerberos, and others (read more).

By default, ShinyStudio defines three levels of access:

  • readers: can only view content from “Apps & Reports”, “Documents”, and “Personal”.
  • admins: can view all site content and develop content with RStudio and VS Code.
  • superadmins: can view and develop site content across multiple instances of ShinyStudio.

Admin/Superadmin landing page:

Readers:

To apply a custom security configuration, modify the ShinyProxy configuration file for the site. All available options are detailed here.

./sites/8080.yml

Open 8080.yml and edit the following lines as desired:

authentication: simple
users:
  - name: superadmin
    password: *change*me*
    groups: superadmins
  - name: admin
    password: *change*me*
    groups: admins
  - name: user
    password: *change*me*
    groups: readers

After modifying any part of the configuration, stop and re-setup the site with:

Multiple Sites

Multiple instances of ShinyProxy can be mapped to different ports in order to segment content or provide unique customizations.

The configs below will setup two unique, independent instances of ShinyStudio, hosted on ports 8080, 8081.

./sites/8080.yml
./sites/8081.yml

Shared Content

It is possible to have multiple sites with independent configurations have access to the same content. To do this, name the file PORT_SITEID.yml, where PORT is the port to broadcast on, and SITEID is the SITEID of the site that already has content.

./sites/8080.yml
./sites/8081_8080.yml